<template>
  <div  class="sousuo">
    <div class="box">搜索</div>
    <div
      class="boxtwo"
      v-for="(item, index) in top"
      :key="index"
      @click="fun(index)"
      :class="{ color: index == i }"
    >
      {{ item }}
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      i: 0,
      top: ["点餐", "评价", "商家"],
    };
  },
  methods: {
    fun(index) {
      this.i = index;
    },
  },
};
</script>

<style lang="scss" scoped>
.sousuo {
  width: 100%;
  height: 50px;
  // background-color: red;
  display: flex;
  align-items: center;
  padding-left: 30px;
  box-sizing: border-box;
  > .color {
    color: red;
  }
  > .box {
    width: 50px;
    height: 30px;
    background-color: rgba(128, 128, 128, 0.415);
    border-radius: 15px;
    text-align: center;
    line-height: 30px;
  }
  > .boxtwo {
    width: 50px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    margin: 0 15px;
  }
}
</style>